package logic

import (
	"context"
	"ykone/ykonerpc/ykonerpc"

	"ykone/api/internal/svc"
	"ykone/api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type ProducecollectLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewProducecollectLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ProducecollectLogic {
	return &ProducecollectLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *ProducecollectLogic) Producecollect(req *types.ProducecollectRequest) (resp *types.Response, err error) {
	// todo: add your logic here and delete this line
	ProduceCollect, err := l.svcCtx.YkOneRpc.ProduceCollect(l.ctx, &ykonerpc.ProduceCollectRequest{
		ProductName: req.ProductName,
		Id:          req.Id,
	})
	if err != nil {
		return &types.Response{
			Message: err.Error(),
			Code:    "500",
			Data:    "",
		}, nil
	}
	return &types.Response{
		Message: "收藏成功",
		Code:    "200",
		Data:    ProduceCollect,
	}, nil

}
